﻿using AuthCenter.Api.Read.Application.Command.Role;
using AuthCenter.Api.Read.Application.Output;
using AuthCenter.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AuthCenter.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class RoleController : ControllerBase
    {
        private readonly IMediator _mediator;
        public RoleController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 显示角色
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<RoleOutput>>> GetRoleShow([FromQuery] GetRoleShowCommand request) 
        {
            return _mediator.Send(request);
        }

        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<UserRoleOutput>>> GetUserIdsByRoleId([FromQuery] GetUserIdsByRoleIdCommand request) 
        {
            return _mediator.Send(request);
        }
    }
}
